<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    
<%@page import="java.sql.*, java.util.*" %>
    
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css" media="screen" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Choose University</title>
</head>
<body>

<% 
	String degreeCountryParam = request.getParameter("degreeCountry");
	session.setAttribute( "degreeCountrySes", degreeCountryParam );
	String degreeCountryIDParam = request.getParameter("countryID");
	String stateIDParam = request.getParameter("stateID");
	

	
	Class.forName("org.postgresql.Driver");
	Connection connect = DriverManager.getConnection("jdbc:postgresql://localhost/tester?user=postgres&password=admin");
	
	PreparedStatement prepStmt;
	ResultSet rset;
	
	
	
	prepStmt = connect.prepareStatement("SELECT * FROM universities WHERE location='"+degreeCountryParam+"'");
	rset = prepStmt.executeQuery();
	Vector universities = new Vector();
	Vector universityID = new Vector();
	while(rset.next())
	{
		universityID.add(rset.getString("id"));
		universities.add(rset.getString("name"));
	}
	
	
	
%>
	
	<%= session.getAttribute("firstNameSes") %>
	<%= session.getAttribute("middleInitialSes") %>
	<%= session.getAttribute("lastNameSes") %><br>
	Citizen of <%= session.getAttribute("citizenSes") %><br>
	Resident of <%= session.getAttribute("residentSes") %><br>
	Address: <%= session.getAttribute("streetSes") %><br>
	City: <%= session.getAttribute("citySes") %><br>
	<%
	if( session.getAttribute("stateSes") != null )
	{ %>
		State: <%= session.getAttribute("stateSes") %><br>
	<%
	}
	else
	{ %>
		Country Code: <%= session.getAttribute("countryCodeSes") %><br>
		
	<% } %>
	Zip: <%= session.getAttribute("zipSes") %><br>
	Phone Number: (<%= session.getAttribute("areaCodeSes") %>) <%= session.getAttribute("phoneSes") %><br>
	<br>
	
	<%
	if ( session.getAttribute("permanentResident") != null)
	{ %>
		Domestic Status: <%= session.getAttribute("permanentResident") %><br>
	<% } %>
	
	Degree Obtained in: <%= session.getAttribute("degreeCountrySes") %><br>
	<br>
	
	From which university did you receive your degree?<br>
	
	
	        	<div id="left_wrapper">
	        	<div id="left">
	        	<p>
	            
					<%
					for (int i=0; i<universities.size()/3; i++){


					            %>	          
	              <a href="8_DegreeDiscipline.jsp?degreeUniversity=<%=universities.get(i)%>&universityID=<%= universityID.get(i) %>"> <%=universities.get(i)%> </a><br>
	            
	
	<% } %>
	            </p>
	        	</div>
	        	</div>
	        	
	        	
	        	<div id="middle_wrapper"> 
	        	<div id="left">
	        	<p>
	            
	            <%
	            for(int i = universities.size()/3; i < 2 * (universities.size()/3); i++)
	            {%>
	            	<a href="8_DegreeDiscipline.jsp?degreeUniversity=<%=universities.get(i)%>&universityID=<%= universityID.get(i) %>"> <%=universities.get(i)%> </a><br>
	            <%}%>
	            
	            </p>
	        	</div>
	        	</div>
	        	
	        	<div id="right_wrapper"> 
	        	<div id="right">
	        	<p>
	        	
	        	<%
	        	for(int i = 2* (universities.size()/3); i < universities.size(); i++)
	        	{%>
	        		<a href="8_DegreeDiscipline.jsp?degreeUniversity=<%=universities.get(i)%>&universityID=<%= universityID.get(i) %>"> <%=universities.get(i)%> </a><br>
	        	<%} %>
	        	
	        	</p>
	        	</div>
	        	</div>
	        	
	        	
	        	
	    
	
		      <br>
		      <br>
		      <form method="GET" action="8_DegreeDiscipline.jsp">
	        	
	        	Other University:<input type="text" name="otherUniversity" /><input type="submit" value="Submit"/>

				</form>
		
	
	
	



<br><br>


</body>
</html>